<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>定义函数</title>
</head>

<body>
  <script>
    // 函数声明
    console.log(factorial(5));
    function factorial(x) {
      // console.log(x);
      if (x <= 1) return 2;
      console.log(x);
      return x * factorial(x - 1)
    }
    // 函数表达式
    let tensquared = function (x) { return x * x; }(10)
    console.log(tensquared);
    // 这里是函数声明
    function fun() {
      console.log("funciton1");
    }
    var a = fun;
    a(); //function1
    // 这里是函数表达式
    var del = function (a, b) {
      return a - b;
    }
    console.log(del(9, 3));//6

    var mul = function multiplay(a, b) {
      console.log(a * b);
      console.log(multiplay);
    }
    mul(3, 3)//9
    console.log(multiplay(2, 3))//error multiplay is not defined
  </script>
</body>

</html>